﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace WallNaming
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdWallNamingManagement : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			Result result2;
			try
			{
				if (cmdData == null)
				{
					throw new System.ArgumentNullException("commandData");
				}
				WallNamingManager wallNamingManager = new WallNamingManager(cmdData);
				Result result = wallNamingManager.Naming(ref msg);
				if (result != null)
				{
					result2 = result;
				}
				else
				{
					result2 = Autodesk.Revit.UI.Result.Succeeded;
				}
			}
			catch (Exception ex)
			{
				msg = ex.Message;
				result2 = Autodesk.Revit.UI.Result.Failed;
			}
			return result2;
		}
	}
}
